﻿using System;
using System.Web;
using System.Web.Routing;

namespace MiniProfilerWebFormsEnabler
{
    public class MiniProfilerRouteHandler : IRouteHandler
    {
        public const string ENABLED_KEY = "enabled";
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            requestContext.HttpContext.Items.Add(ENABLED_KEY, Convert.ToBoolean(requestContext.RouteData.Values[ENABLED_KEY]));
            return new MiniProfilerHttpHandler(requestContext);
        }
    }
}
